In a video coding system, the video data are subject to various processing such as prediction, transform, quantization, deblocking, and adaptive loop filtering. Along the processing path in the video coding system, certain characteristics of the processed video data may be altered from the original video data due to the operations applied to video data. For example, the mean value of the processed video may be shifted. Intensity shift may cause visual impairment or artifacts, which is especially more noticeable when the intensity shift varies from frame to frame. Therefore, the pixel intensity shift has to be carefully compensated or restored to alleviate the artifacts. Some intensity offset schemes have been used in the field. The intensity offset scheme usually classifies each pixel in the processed video data into one of multiple categories according to a context selected. For example, the context may be the pixel intensity of the processed video data. Alternatively, the context may be a combination of a current pixel and its surrounding pixels. A characteristic measurement is derived according to the selected context and a category is determined according to the measured characteristic. For each category, intensity shift between the original pixels and the processed pixels is determined. The intensity shift is also called the “offset value” in this disclosure. Accordingly, the offset value is applied to the processed pixels belonging to the category to compensate the intensity shift. The process of intensity shift compensation or restoration for processed video data based on the category of each pixel is termed “sample adaptive offset (SAO)” in this disclosure.
The conventional SAO scheme often determines the category for the pixels on a frame by frame or slice by slice basis. However, picture contents often are dynamic and the characteristic may vary from frame to frame and/or from region to region within a frame. Therefore, it is desirable to develop a sample adaptive offset scheme that can take into consideration of the dynamic characteristics within a frame using a region partition scheme to adaptively partition the processed video data into regions having different sizes. Furthermore, the conventional SAO scheme always uses a fixed context to determine a category for the pixel of processed video data. For example, the SAO may only use a fixed 16-band band offset (BO) for sample adaptive offset. In another example, the SAO may only used a 3×3 window as the context to determine the category for the pixel of processed video data. It is desirable that the sample adaptive offset scheme can adaptively select a SAO type from a group of SAO types to tailor the SAO process to the characteristics of processed video data and to achieve better quality. Accordingly, a sample adaptive offset scheme is disclosed herein that can exploit the dynamic characteristics of processed video data.